package com.eduran.tuts.jfundamentals.model;

import java.util.Scanner;

/**
 * Created by eduran on 14.10.2014.
 */
public class ClassAverage {
    public static void main(String[] args) {

        Scanner input = new Scanner(System.in);

        int total = 0;
        int gradeCounter = 0;

        System.out.println("Enter grade or -1 to quit: ");
        int grade = input.nextInt();

        while(grade != -1){
            total = total + grade;
            gradeCounter = gradeCounter + 1;
            System.out.println("Enter grade or -1 to quit: ");
            grade = input.nextInt();
        }

        if (gradeCounter != 0) {
            double average = (double) total / gradeCounter;
            System.out.printf("%n Total of the %d grades entered is %d%n", gradeCounter, total);
            System.out.printf("Class average is %.2f%n", average);
        }
        else {
            System.out.println("No grades were entered");
            System.out.println(5%10);
        }
    }
}
